﻿// -----------------------------------------------------------------------
//    This file is part of TSGE.
//
//    TSGE is free software: you can redistribute it and/or modify
//    it under the terms of the GNU General Public License as published by
//    the Free Software Foundation, either version 2 of the License, or
//    (at your option) any later version.
//
//    TSGE is distributed in the hope that it will be useful,
//    but WITHOUT ANY WARRANTY; without even the implied warranty of
//    MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
//    GNU General Public License for more details.
//
//    You should have received a copy of the GNU General Public License
//    along with TSGE.  If not, see <http://www.gnu.org/licenses/>.
// -----------------------------------------------------------------------

namespace tsge.Classes
{
    using System;
    using System.ComponentModel;

    /// <summary>
    /// Server Entry Class Implementation
    /// 
    ///     Inherits:
    ///         - INotifyPropertyChanged
    /// </summary>
    public class ServerEntry : INotifyPropertyChanged
    {
        /// <summary>
        /// Internal copy of the server x spawn position.
        /// </summary>
        private Int32 m_vSpawnX;

        /// <summary>
        /// Internal copy of the server y spawn position.
        /// </summary>
        private Int32 m_vSpawnY;

        /// <summary>
        /// Internal copy of the server address.
        /// </summary>
        private Int32 m_vServerAddress;

        /// <summary>
        /// Internal copy of the server name.
        /// </summary>
        private String m_vServerName;

        /// <summary>
        /// Public PropertyChanged event to register onto.
        /// </summary>
        public event PropertyChangedEventHandler PropertyChanged;

        /// <summary>
        /// Default Constructor
        /// </summary>
        public ServerEntry()
        {
            this.SpawnX = -1;
            this.SpawnY = -1;
            this.ServerAddress = -1;
            this.ServerName = String.Empty;
        }

        /// <summary>
        /// Invokes the PropertyChanged event if one is set.
        /// </summary>
        /// <param name="propName">Name of the property being updated.</param>
        private void NotifyPropertyChanged(String propName)
        {
            if (this.PropertyChanged != null)
            {
                this.PropertyChanged(this, new PropertyChangedEventArgs(propName));
            }
        }

        /// <summary>
        /// Gets or sets the x spawn location of this server entry.
        /// </summary>
        public Int32 SpawnX
        {
            get { return this.m_vSpawnX; }
            set { this.m_vSpawnX = value; this.NotifyPropertyChanged("SpawnX"); }
        }

        /// <summary>
        /// Gets or sets the y spawn location of this server entry.
        /// </summary>
        public Int32 SpawnY
        {
            get { return this.m_vSpawnY; }
            set { this.m_vSpawnY = value; this.NotifyPropertyChanged("SpawnY"); }
        }

        /// <summary>
        /// Gets or sets the server address of this server entry.
        /// </summary>
        public Int32 ServerAddress
        {
            get { return this.m_vServerAddress; }
            set { this.m_vServerAddress = value; this.NotifyPropertyChanged("ServerAddress"); }
        }

        /// <summary>
        /// Gets or sets the server name of this server entry.
        /// </summary>
        public String ServerName
        {
            get { return this.m_vServerName; }
            set { this.m_vServerName = value; this.NotifyPropertyChanged("ServerName"); }
        }
    }
}
